-
Notifications
You must be signed in to change notification settings - Fork 233
Fix Android build: enable linux-raw-sys and exclude Android-unsupported Linux userspace features
#1528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
It's unclear to me why CI failed here. Would you mind updating this and trying again? |
|
Here it is ..... @sunfishcode , now it passed all of the tests and checks. Hope now it will help. |
|
This is now released in rustix 1.1.3. |
|
#1095 🤔 |
|
If you have new information, please post it. |
|
Confirming for everyone here that this does not make it so Android uses the raw system call backend for Linux. Android still always uses the libc backend. This just brings in some constants for Android to use. |
Enable access to Linux kernel types on Android targets while excluding a small set of Linux userspace features that are not available on Android (XDP, io_uring, certain
STATXconstants), restoring Android builds without changing Linux behavior.Motivation / Background
Recently the crate started failing to build for Android targets with errors like:
Root cause: Android had been explicitly excluded from the
linux_raw_dep/linux-raw-syspath inbuild.rs/Cargo.toml, which prevented Android builds from getting Linux kernel constant / syscall/type definitions that are required even when using the libc backend. Bionic (Android libc) does not expose all kernel-level constants and some syscalls/constants are only available vialinux-raw-sys. At the same time, Android’s userspace is missing a few advanced Linux-only features and constants (e.g.SOL_XDP,RWF_*) — those should remain disabled on Android rather than enabled.This PR restores Android builds by enabling access to
linux-raw-syson Android targets, and then selectively disables features that truly require Linux userspace support not present in Bionic.What this PR changes
High level
linux-raw-syskernel types for Android targets so Android can access kernel constants/types it needs.#[cfg(...)]guards so features not supported by Bionic (XDP, io_uring, certain STATX usages) remain disabled on Android.Rationale / Technical explanation
Android uses the Linux kernel, so kernel-level types and syscall constants are valid on Android and MUST be available to the crate (via
linux-raw-sys) so code paths that depend on kernel definitions compile.However, Android’s userspace (Bionic) does not expose certain Linux userspace constants and features:
SOL_XDPand related constants are not present in Bionic. XDP is a Linux networking acceleration feature that is not applicable to Android userspace; those code paths are guarded so they are only enabled for desktop/server Linux.RWF_*(e.g.,RWF_NOWAIT,RWF_DSYNC) flags and other io_uring-related userspace support may be absent in Bionic. io_uring code is therefore excluded on Android targets.linux-raw-sys, causing ambiguity; adding Android to the exclusion list resolves the ambiguity and keeps the definitions consistent.Net effect: Android gets what it needs from kernel types; Linux retains full feature set. No behavior changes for Linux targets.
Testing performed
All CI workflow targets tested locally/in-workflow:
Android (all passing)
aarch64-linux-android(default &use-libcfeatures)armv7-linux-androideabi(use-libc)x86_64-linux-android(use-libc)i686-linux-android(use-libc)Linux (all passing)
all-apisfeature buildsuse-libc,all-apisbuildslinux_latest,all-apisbuilds(These are the results from my test runs; CI logs are attached in the workflow that exercised all Android and Linux variants.)
Changes are intentionally minimal and scoped:
Linux behavior is unchanged —
#[cfg(all(linux_raw_dep, target_os = "linux"))]keeps full Linux feature set intact.Tests and CI flows covering both Android and Linux have been exercised and pass.
References (for reviewer verification)